<!DOCTYPE html>
<!-- extends表明此页面继承自 base.html 文件 -->
{% extends "base.html" %}
<!-- 写入 base.html 中定义的 title -->
{% block title %}
    首页
{% endblock title %}

<!-- 写入 base.html 中定义的 content -->
{% block content %}

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="{% static 'ueditor/ueditor.config.js' %}"></script>
    <script src="{% static 'ueditor/ueditor.all.min.js' %}"></script>
    <script type="text/javascript">
        var ue = UE.getEditor('body_01',{'initialFrameWidth': 700, 'initialFrameHeight': 500,'serverUrl': "/ueditor/controller/?imagePathFormat=images/&filePathFormat=files/"});
    </script>
</head>
<body>
    <div class="container" style="margin:auto;width: 50%;padding: 2% 0 2% 0;">
    <div class="row">
        <div class="col-12">
            <br>
            <br>
            <br>
            <form enctype="multipart/form-data" method="post" action=".">
                {% csrf_token %}
                <div class="form-group">
                    <label for="title">文章标题</label>
                    <!-- 在 value 属性中指定文本框的初始值为旧的内容，即 article 对象中的 title 字段 -->
                    <input type="text" class="form-control" id="title" name="title" value="{{ article.title }}">
                </div>

            <!-- 文章标签 -->
                 <div class="form-group">
                    <label for="tags">文章标签</label>
                    <input type="text" class="form-control col-3" id="tags" name="tags" value="{% for tag in article.tags.all %}{{ tag }},{% endfor %}">
                </div>
                <div class="form-group">
                    <label for="body">文章正文</label>
                    <!-- 文本域不需要 value 属性，直接在标签体中嵌入数据即可 -->
                    <textarea type="text" class="ueditor" id="body_01" name="body">{{ article.body|safe }}</textarea>
                
                </div>

                 <div class="form-group">
                    <label for="status">文章状态</label>
                    <!-- 文本域不需要 value 属性，直接在标签体中嵌入数据即可 -->
                 <select name="status" id="status"> {% for statu in article_post_form.status %}{{ statu }}{% endfor %}</select>
                 <span>当前状态：{{ article.get_status_display }}</span>
                </div>
                <!-- 文章标题图 -->
                <div class="form-group">
                    <!-- 标题图 -->
                    <label for="avatar">文章图片</label><span>（当前图片：<img src=" {{ article.avatar.url }}" alt="#" style="width: 20%;height:30%;">）</span>
                    <!-- 文本框 -->
                    <input type="file" class="form-control-file" id="avatar" name="avatar"placeholder="文章标题图">

                </div>
                <button type="submit" class="btn btn-primary">更新</button>
                
            </form>
        </div>
    </div>
</div>


{% endblock content %}
</body>
</html>